package com.StephenHu.service.impl;

import com.StephenHu.dao.ProductDao;
import com.StephenHu.entity.Product;
import com.StephenHu.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * @author steph
 */
@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductDao productDao;

    @Override
    public List<Product> list() {
        return productDao.list();
    }

    @Override
    public boolean add(Product product) {
        int result = productDao.add(product);
        return result > 0;
    }

    @Override
    public boolean update(Product product) {
        int result = productDao.update(product);
        return result > 0;
    }

    @Override
    public boolean delete(Product product) {
        int result = productDao.delete(product.getId());
        return result > 0;
    }
}
